<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	var num=parseInt(Math.random()*100);
	function pf() {
		var input=document.getElementById("d1").value;
		var span=document.getElementById("s1");
		if(isNaN(input)){
			span.innerHTML='请输入数字!';
		}else{
			span.innerHTML=parseInt(input*input);
		}
	}
	function su() {
		var input=document.getElementById("d2").value;
		var span=document.getElementById("s2");
		if(isNaN(input)){
			span.innerHTML='请输入数字!';
		}else if(input>num){
			span.innerHTML="大了";
		}else if(input<num){
			span.innerHTML="小了";
		}else{
			span.innerHTML="对了";
		}
	}
	function jc() {
		var input=document.getElementById("d3").value;
		var span=document.getElementById("s3");
		if(isNaN(input)){
			span.innerHTML='请输入数字!';
		}else if(input<0){
			span.innerHTML='小于0的数字没有阶乘';
		}else if(input==0){
			span.innerHTML=1;
		}else{
			var n=1;
			console.log(parseInt(input));
			for(var i=2;i<=input;i++){
				n=i*n;
			}
			span.innerHTML=n;
		}
	}
	
</script>
</head>
<body>
	<p>
		<input type="text" id="d1"/>
		<input type="button" value="平方" onclick="pf();"/>
		<span id="s1"></span>
	</p>
	<p>
		<input type="text" id="d2"/>
		<input type="button" value="猜数字" onclick="su();"/>
		<span id="s2"></span>
	</p>
	<p>
		<input type="text" id="d3"/>
		<input type="button" value="阶乘" onclick="jc();"/>
		<span id="s3"></span>
	</p>
</body>
</html>